<template>
  <div class="common-card">
    <el-card shadow="hover">
      <div class="title">{{ title }}</div>
      <div class="value">{{ value }}</div>
      <div class="chart">
        <!-- props(传递的是值)和slots(传递是html结构内容)本质是一样 都是用来展示组件被调用的时候传入的内容的 -->
        <slot name="default" />
      </div>
      <div class="line"></div>
      <div class="footer">
        <slot name="footer" />
      </div>
    </el-card>
  </div>
</template>

<!-- 封装一个通用的卡片 接受2个props 2个slots -->
<!-- 当前这个通用卡片基于el-card来实现 =>二次封装组件库-->
<script>
export default {
  props: ["title", "value"],
};
</script>

<style lang="scss" scoped>
.common-card{
  .title{
    font-size: 12px;
    color: #777;
    letter-spacing: 1px;
  }
  .value {
    font-size: 24px;
    font-weight: 600;
    margin-top: 10px;
  }
  .chart {
    height: 50px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
  }
  .line {
    margin-top: 18px;
    border-top: 1px solid #ddd;
  }
  .footer {
    margin-top: 10px;
  }
}
</style>
